<?php

function genlinktacpham($matp) {
    echo base_url("index.php/product/detail?matp=" . $matp);
}

function genlinktacgia($matg, $tentg) {
    echo "Tác giả: <a href='" . base_url('index.php/tacgia/?matg=' . $matg) . "'>  $tentg </a>";
}

function genlinknxb($manxb, $tennxb) {
    echo "Nhà xuất bản: <a href='" . base_url('index.php/nxb/?manxb=' . $manxb) . "'>  $tennxb </a>";
}
?>
<div id="container-wrapper">
    <div id="container1">
        <div class="wrapper-inner">
            <div class="left-70" >                                                    
                <div class="wrapper-row">

                    <!--                -->

                    <!-- hien thi danh sach san pham  san pham / 1 hang -->
                    <?php
                    // var_dump($tacgias);
                    $count = 1;
                    echo "<div class='row '>";
                    ?><div class="muc line-height33"> Sách theo danh mục <?php echo $title; ?></div>
                    <?php
                    $x = 1;
                    foreach ($products as $row) {
                        
                        $giaban = $row["GIABAN"];
                        $matp = $row["MATP"];
						$hinhanh = base_url('index.php/product/getImage/'.$matp);
                        ?>
                        <figure class="span4 s-product">
                            <div class="s-product-img">
                                <a href="<?php echo base_url("index.php/product/detail?matp=" . $matp); ?> ">
                                    <img src="<?php echo $hinhanh; ?>" alt=""></img>
                                </a>

                            </div>
                            <article class="s-product-det">
                                <h3><a href="<?php echo base_url("index.php/product/detail?matp=" . $matp); ?>">MãTP: <span class="matp"><?= $row['MATP'] ?></span><span class="tentp">  <?= $row['TENTP']; ?></span> </a></h3>
                                <!--<div class="caption"> <p></p> </div>-->
                                <div class="tacgia"> <p><?php genlinktacgia($tacgias[$x]["MATG"], $tacgias[$x]['TENTG']); ?></p> </div>
                                <div class="nxb"> <p><?php genlinknxb($nxbs[$x]["MANXB"], $nxbs[$x]['TENNXB']); ?></p> </div>
                                <div class="cart-price">
                                    <span href="#" class="cart-btn2  add_to_cart"></span>
                                    <span class="price"><?= $giaban; ?></span>
                                </div>
                            </article>

                        </figure>
                        <?php
                        $x+=1;
                    }
                    ?>
                </div>             
                <!--end section row -->


                <!-- ----->
            </div>
           
        </div>
        <div class="right-27">
            <div class="wrapper-row">
                <div class="muc line-height33"> Thể loại sách</div>
                <div>
                    <ul>
                        <?php
                        $dem = count($theloai);
                        //var_dump($dem)
                        for ($i = 0; $i < $dem; $i++) {
                            ?>
                        <li style="border-bottom: 1px dotted #ddd;" >  <a href="<?= base_url("?matl=").$theloai[$i]->MATL ; ?>" class="theloai ">  <?= $theloai[$i]->TENTL; ?></a></li>

                            <?php
                        }
                        ?>
                    </ul>


                </div>
            </div>



        </div>
    </div>
</div>
</div>
</div>